
<div id="actionbar"  class="button-group">
    <a href="{:url('ask/add')}" class="button button-blue"> <i class="iconfont icon-add_icon"></i>创建知识</a>
</div>
<table class="table">
    <thead>
        <tr>
            <th class="w60 fn-tac">排序</th>
            <th>标题</th>
            <th class="w80 fn-tar">价格</th>
            <th class="w80 fn-tac">是否推荐</th>
            <th class="w80 fn-tac">是否置顶</th>
            <th class="w140">更新时间</th>
            <th class="w160 fn-taj">操作</th>
        </tr>
    </thead>
    <tbody>
        {foreach $lists as $vo}
        <tr>
            <td class="fn-tac"><input name="sort" class="fn-tac w40 input input-mini" type="text" value="{$vo['sort']}" id="{$vo.id}" /></td>
            <td><a href="{:url('ask/edit',['id'=>$vo.id])}">{$vo.title}</a></td>
            <td class="fn-tar">{$vo.price > 0 ? '￥'.$vo.price : '免费'}</td>
            <td class="fn-tac">
                <a class="isAd" url="{:url('ask/isAd',['id'=>$vo.id])}" href="javascript:;" title="置顶/取消">
                    {if $vo.is_ad}<span class="badge bg-green">推荐</span>{else}<span class="badge">推荐</span>{/if}
                </a>
            </td>
            <td class="fn-tac">
                <a class="isTop" url="{:url('ask/isTop',['id'=>$vo.id])}" href="javascript:;" title="置顶/取消">
                    {if $vo.is_top}<span class="badge bg-green">置顶</span>{else}<span class="badge">置顶</span>{/if}
                </a>
            </td>
            <td>{$vo.update_time|date='Y-m-d H:i'}</td>
            <td class="button-group fn-tac">
                <a class="button" href="{:url('ask/edit',['id'=>$vo.id])}"><i class="iconfont icon-edit"></i>编辑</a>
                <a class="button isDel" url="{:url('ask/delete',['id'=>$vo.id])}" href="javascript:;"><i class="iconfont icon-lajixiang"></i>删除</a>
            </td>
        </tr>
        {/foreach}
    </tbody>
</table>
{$lists|raw}
<script type="text/javascript">
    Do('base', 'layer', function () {
        $('.isDel').isDel();
        sort("{:url('ask/sort')}");
        $('.isAd').click(function () {
            var url = $(this).attr("url");
            parent.layer.confirm('确认要设置推荐',{ icon: 3,title: '友情提示' }, function (index) {
                $.getJSON(url,function (data) {
                    parent.layer.alert(data.msg,{icon:1});
                    window.location.reload();
                });
                parent.layer.close(index);
            });
        })
        $('.isTop').click(function () {
            var url = $(this).attr("url");
            parent.layer.confirm('确认要设置置顶',{ icon: 3,title: '友情提示' }, function (index) {
                $.getJSON(url,function (data) {
                    parent.layer.alert(data.msg,{icon:1});
                    window.location.reload();
                });
                parent.layer.close(index);
            });
        })
    })
</script>